package site.madai.jobs;

import com.alibaba.dubbo.config.annotation.Reference;
import org.springframework.stereotype.Component;
import site.madai.service.OrderSettingService;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * @author ：小海螺
 * @date ：Created in 2019/7/8 10:51
 * @description ：
 * @version: 1.0
 */
@Component
public class ClearOrdersettingJobs {

    @Reference
    private OrderSettingService orderSettingService;

    /**
     * 定期删除过期预约
     */
    public void clearOrderSettings() {

        //获取当前时间的上个月的日期
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        Calendar c = Calendar.getInstance();
        c.setTime(new Date());
        c.add(Calendar.MONTH, -1);
        Date m = c.getTime();
        String date = format.format(m);
        System.out.println(date);

        //调用orderSettingService  执行方法
        orderSettingService.clearOrderSettings(date);
    }
}
